<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset="utf-8"/>
<title>Đăng nhập</title>
<link rel="stylesheet" href="Css/cc.css"></link>
</head>
<body>
<div class="wrapper">
<?php include 'menu.php';?>
<div class="content">
    <div class="log">
        <?php include 'connect.php'; ?>
        <form method="post" action="login.php">
        <div><input type="text" name="txtuser"></input><input class="log_button" type="submit" name="login" value="Đăng nhập"></input></div>
        <div><input type="password" name="txtpass"></input><input class="log_button" type="submit" value="Hủy bỏ" name="can"></input></div>
        <div></div>
        </form>
        <?php
if(isset($_POST["can"]))
{
    header('Location:/projectshopqa/index-.php');
}
if(isset($_POST["login"])){
    $uname = $con->real_escape_string($_POST["txtuser"]);
    $password =$con->real_escape_string($_POST["txtpass"]);
    $md5pass=md5($password);
    $resu = "SELECT * FROM members WHERE user=\"$uname\" and pass=\"$md5pass\"";
    $rows = $con->query($resu);
    $count = mysqli_num_rows($rows);
    if($count >= 1) {
        $user = mysqli_fetch_row($rows);
        $_SESSION['user']['username'] = $user[0]; 
        $_SESSION['user']['role'] = $user[2]; 
        $_SESSION['user']['name'] = $user[3];
        header('Location:/projectshopqa/index-.php');
    }
    else 
        {
        echo "Bạn cần nhập đúng tên và mật khẩu!";
        }
}
?>
    </div>
</div>
<div class="footer">
We are... Mr.Chuot Tru, Mr.Minh Ho
<hr  width="20%" style="margin-left:40%; margin-top:8px;"/>
<pre><br /><br />
Coppyright: Aitieducation
</pre>
</div>
</div>
</div>
</body>
</html>
</html>